import type { InterviewQuestionsAdd } from '@/models/InterviewQuestions/InterviewQuestionsAdd'
import type { InterviewQuestionsEdit } from '@/models/InterviewQuestions/InterviewQuestionsEdit'
import type { InterviewQuestionsSearch } from '@/models/InterviewQuestions/InterviewQuestionsSearch'
import type { InterviewQuestionsPage } from '@/models/InterviewQuestions/InterviewQuestionsPage'
import type { Pagination } from '@/models/Pagination/Pagination'
import { http } from '@/utils/http'

const baseUrl = import.meta.env.VITE_API_PROXY ? `/api/interview/questions` : `/interview/questions`

export async function page(data: Pagination & Partial<InterviewQuestionsSearch>) {
  return await http.post<InterviewQuestionsPage>(`${baseUrl}/list`, data, {
    params: {
      page: data.page,
      size: data.size,
    },
  })
}

export async function add(data: InterviewQuestionsAdd) {
  return await http.post(`${baseUrl}`, data)
}

export async function edit(data: InterviewQuestionsEdit) {
  return await http.put(`${baseUrl}`, data)
}

export async function del(id: number) {
  return await http.delete(`${baseUrl}`, {
    params: { id },
  })
}

export async function view(id: number) {
  return await http.get(`${baseUrl}/${id}`)
}
